/**
 * <p>
 * 表格配置
 *
 * @Author：Roy
 * @Description：碳减数据
 * @Date：Create by 2023-12-01 10:45:08
 */
// 隐藏操作按钮的规则配置，字段名：isEdit
const isHidden = (list, row) => {
  const { isEdit } = row || {}
  return list.includes(String(isEdit))
}

const headerConfig = {
  'emission-intensity-data': [
    {
      prop: 'solidifyDate',
      name: '数据时间',
      minWidth: 110,
      format: {
        type: 'date',
        showType: '{y}-{m}-{d} {h}时'
      }
    },
    {
      prop: 'projectName',
      name: '所属项目',
      minWidth: 110
    },
    {
      prop: 'sceneInfoName',
      name: '所属场景',
      minWidth: 170
    },
    {
      name: '面积（㎡）',
      minWidth: 120,
      formatter: (row) => {
        return row.area || row.floorArea || row.edificeFloorArea || row.projectFloorArea;
      }
    }, {
      prop: 'carbonEmission',
      name: '碳排放量（kgCO2）',
      minWidth: 120
    },
    {
      name: '碳排放强度（kgCO2/㎡）',
      minWidth: 150,
      formatter: (row) => {
        let area = row.area || row.floorArea || row.edificeFloorArea || row.projectFloorArea;
        if (area == null || parseFloat(area) === 0.0) {
          return null
        }
        return (row.carbonEmission / area).toFixed(2)
      }
    },
    {
      name: '操作',
      width: 100,
      fixed: 'right',
      thStyle: { 'text-align': 'left' },
      operateList: [
            // {
        //   type: 'btnText',
        //   label: '编辑',
        //   id: 'emission-intensity-data-edit',
        //   authId: 'ecp-admin:carbonEmissionData:update',
        //   config: { type: 'text' },
        //   style: { color: 'rgb(66, 185, 131)' },
        //   hidden: (val) => {
        //     return false // !isHidden(['1'], val)
        //   }
        // },
        {
          type: 'btnText',
          label: '删除',
          id: 'emission-intensity-data-delete',
          authId: 'ecp-admin:emissionIntensityData:deleteById',
          isMore: true,
          config: { type: 'text' },
          style: { color: '#ff0000' },
          hidden: (val) => {
            return false // !isHidden(['1'], val)
          }
        }
      ]
    }
  ]
}

export default {}
export { headerConfig }
